<template>
	<view>
		<Navigation ref="Navigation" v-show="selectedIndex !== 2 && isLogin"></Navigation>
		<view v-if="$store.state.isLogin || isLogin">
			<view v-show="selectedIndex === 0">
				<Home></Home>
			</view>
			<view v-show="selectedIndex === 1">
				<List></List>
			</view>
			<view v-show="selectedIndex === 2">
				<My></My>
			</view>
			<CustomTabBar v-show="$store.state.isShowTabBar" ref="CustomTabBar"></CustomTabBar>
		</view>
		<view v-else>
			<My></My>
		</view>
	</view>
</template>

<script>
	import { mapState, mapMutations } from 'vuex';
	
	export default {
		name: 'Main',
		data() {
			return {
				onStart: true
			}
		},
		created() {
			console.log('created  Test：' + this.isLogin)
			console.log('created  Test：' + this.$store.state.isLogin)
		},
		mounted() {
			this.setTitle()
		},
		watch: {
			selectedIndex(newValue, oldValue) {
				this.setTitle()
				if (newValue === 0) {
					
				} else if (newValue === 1) {
					
				} else if (newValue === 2) {
					
				}
			}
		},
		computed: {
			...mapState(['selectedIndex', 'isLogin'])
		},
		methods: {
			setTitle() {
				this.$refs.Navigation.setTitle(this.$store.state.list[this.$store.state.selectedIndex].title)
			}
		}
	}
</script>

<style scoped>

</style>
